package com.hl.payServer.model;


import com.hl.payServer.model.enums.TradeState;

import javax.persistence.Column;
import java.io.Serializable;

/**
 * 支付平台返回给业务平台的请求结果
 */
public class PayResponse implements Serializable {
    /**
     * SUCCESS/FAIL
     * ResultModel中的success 是通信状态，支付状态看returnCode
     * 这里的returnCode是真正的成功/失败
     */
    private String returnCode;
    /**
     * 交易状态或请求状态
     */
    private String tradeState;

    //失败返回值
    /**
     *失败代码
     */
    private String errCode;
    /**
     *失败原因
     */
    private String errMsg;

    //成功返回值
    /**
     * 支付平台唯一单号
     */
    @Column(name = "tradeNo")
    private String tradeNo;
    /**
     * 下游业务系统请求业务单号
     */
    @Column(name = "bizNo")
    private String bizNo;
    /**
     * 外部交易号(实际支付号)
     * 交易平台返回的交易号(支付宝自己的交易单号)
     */
    @Column(name = "outTradeNo")
    private String outTradeNo;
    /**
     * 下单成功的返回值
     * app支付需要的orderstr，二维码支付的二维码字符串等
     */
    private String responseBody;


    /*****************以下是原来用的，需要兼容，新的方法尽量不要使用***************/
   /* *//**
     * ecod
     *//*
    private String content;
    *//**
     * 微信MICROPAY返回的支付单号
     *//*
    private String transactionId;*/


    /**
     * 给各种号赋值
     * @param tradeNo       支付平台生成唯一单号
     * @param bizNo         下游业务系统请求时传入的号码
     * @param outTradeNo    支付宝/微信生成的交易单号
     */
    public void setNosPayResponse(String tradeNo, String bizNo, String outTradeNo){
        this.tradeNo = tradeNo;
        this.bizNo = bizNo;
        this.outTradeNo = outTradeNo;
    }
    /**
     * 成功赋值
     * @param responseBody
     * @param tradeState
     */
    public void setSuccessPayResponse(String tradeState, String responseBody){
        this.returnCode = TradeState.SUCCESS.type();
        this.tradeState = tradeState;
        this.responseBody = responseBody;
    }

    /**
     * 失败赋值
     * @param errCode
     * @param errMsg
     * @param tradeState
     * @param responseBody
     */
    public void setFailPayResponse( String errCode, String errMsg, String tradeState, String responseBody){
        this.returnCode = TradeState.FAIL.type();
        this.errCode = errCode;
        this.errMsg = errMsg;
        this.tradeState = tradeState;
        this.responseBody = responseBody;
    }

    public String getReturnCode() {
        return returnCode;
    }

    public void setReturnCode(String returnCode) {
        this.returnCode = returnCode;
    }

    public String getTradeState() {
        return tradeState;
    }

    public void setTradeState(String tradeState) {
        this.tradeState = tradeState;
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public String getBizNo() {
        return bizNo;
    }

    public void setBizNo(String bizNo) {
        this.bizNo = bizNo;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getResponseBody() {
        return responseBody;
    }

    public void setResponseBody(String responseBody) {
        this.responseBody = responseBody;
    }
}
